#ifndef _GRAPHICS_MAP_BLOCK_H
#define _GRAPHICS_MAP_BLOCK_H

#include <Ogre.h>
#include <CEGUIXMLAttributes.h>
#include <CEGUIXMLHandler.h>


namespace CEGUI
{
	class XMLHandler;
}


namespace Graphics
{
	class MaterialAtlas;
	class MapBlock  
	{

	private:
		std::string mDescription;
		unsigned short mId;
		bool mIsEmpty,mIsWall,mIsFloor;
		bool mIsSlope;
		DWORD mFlagDef;
		Ogre::Entity *mAdditionalObject;
		Ogre::MaterialPtr mAdditionalMaterial;
		// matgloss to be used instead of the "more difficult" way
		WORD mDefaultMatgloss;
		bool mHasDefaultMatgloss;
	public: 
		MapBlock();
		~MapBlock();
		Ogre::Entity *getEntity(/*some material choice, etc */); 

		bool isEmpty() {return mIsEmpty;}
		bool isWall() {return mIsWall;}
		bool isFloor() {return mIsFloor;}
		bool isSlope() {return mIsSlope;}
		bool hasDefaultMatgloss() {return mHasDefaultMatgloss;}
		WORD getDefaultMatgloss() {return mDefaultMatgloss;}

	public:
		class XMLHandler :public CEGUI::XMLHandler
		{
			static std::string cDefaultMeshName;
			static std::string cDefaultMaterialName;
			std::vector<MapBlock*> mBlockMap;			
			int mWorkingId;
			bool mAdditionalObjectMode;
			Ogre::SceneManager *mManager;
			
			std::string mElement;

			Graphics::MaterialAtlas *mMaterialAtlas;
		public:
			XMLHandler(Ogre::SceneManager *manager,Graphics::MaterialAtlas *atlas);

			void elementStart(const CEGUI::String& element, const CEGUI::XMLAttributes& attributes);
            void elementEnd(const CEGUI::String& element);
			void text(const CEGUI::String& text);
			std::vector<MapBlock*> &retrieveBlockMap();
		};
//tolua_begin
	};
}; // namespace Graphics
//tolua_end
#endif